//
//  ALGPSUtil.m
//  ALUtils_Example
//
//  Created by hcs on 2018/12/3.
//  Copyright © 2018年 anlun. All rights reserved.
//

#import "ALGPSUtil.h"
#import "ALGPSManager.h"
#import "MBProgressHUD.h"

@interface ALGPSUtil()
@property (nonatomic, copy) ALGPSUtilBlock theBlock;
@property (strong, nonatomic) NSMutableDictionary *cities;
@property (strong, nonatomic) NSMutableArray *keys; //城市首字母

@property (nonatomic, strong) NSString *locationCity; //当前定位城市
@property (nonatomic, assign) BOOL locationServicesEnabled;//定位权限
@end
@implementation ALGPSUtil
AL_DEF_SINGLETON(ALGPSUtil)
- (void)getGPSLocation{
    if ([CLLocationManager locationServicesEnabled] && ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorizedWhenInUse || [CLLocationManager authorizationStatus] == kCLAuthorizationStatusNotDetermined || [CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorizedAlways)) {
        //定位功能可用
    }else if ([CLLocationManager authorizationStatus] ==kCLAuthorizationStatusDenied) {
        //定位不能用
        return;
    }
    
    [ALGPSManager getGPSLocation:^(CLLocationDegrees latitude, CLLocationDegrees longitude) {
        if (self.theBlock) {
            self.theBlock(latitude, longitude);
        }
        //        [GPSManager getPlacemarkWithCoordinate2D:CLLocationCoordinate2DMake(latitude, longitude) closure:^(Placemark *placemark) {
        //
        //
        //        }];
    }];
}
- (void)curLocationCityFinish:(void(^)(double latitude,double longitude))block{
    self.theBlock = block;
    [self getGPSLocation];
}

@end
